import * as lark from '@larksuiteoapi/node-sdk';

const client = new lark.Client({
  appId: 'cli_a69966fdab7d100b',
  appSecret: 'rPd0U2Y1HxjZC8XCqAkAlcVkdqtzWYGB',
  appType: lark.AppType.SelfBuild,
  domain: lark.Domain.Feishu,
});


/**
 * 调用飞书OCR识别
 */
export function doOCR(base64Img: string) {
  return new Promise((yes, err) => {
    // console.log(111);
    client.optical_char_recognition.v1.image.basicRecognize({
      data: {
        image: base64Img
      }
    }).then((res) => {
      // console.log("结果", res);
      if (res.code === 0 && res?.data?.text_list) {
        yes(res.data.text_list)
      } else {
        err()
      }
    }).catch((error) => {
      err(error)
      // console.log("出错", err);
    })
  })
}